/**
 * @file   PropertyInfo.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-16
 * @brief  DataBus Property Info.
 *
 * Copyright (C) 2013  Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBDATABUS_COMMON_PROPERTYINFO_H
#define LIBDATABUS_COMMON_PROPERTYINFO_H

#include <QtCore/QString>
#include <DataBus/Common/Common.h>

namespace DataBus
{
/**
 * @brief The PropertyInfo class
 */
class DATABUSSHARED_EXPORT PropertyInfo
{
public:
    /**
     * @brief Constructor for PropertyInfo
     */
    PropertyInfo();

    /**
     * @brief Constructor for PropertyInfo
     *
     * @param id                Property ID
     * @param dataType          Property Data Type
     * @param accessPermission  Property Access Permission
     * @param name              Property Name
     */
    PropertyInfo(const quint8 id,
                 const DataType dataType,
                 const AccessPermission accessPermission,
                 const QString &name);

    /**
     * @brief Copy constructor for PropertyInfo
     *
     * @param copyin    Original value
     */
    PropertyInfo(const PropertyInfo &copyin);

    /**
     * @brief Operator =
     *
     * @param rhs   Value on the right side of the operator =
     *
     * @return Property Info
     */
    PropertyInfo & operator=(const PropertyInfo &rhs);

    /**
     * @brief Check if Property Info is valid
     *
     * @retval true     Property Info is valid
     * @retval false    Property Info is invalid
     */
    bool isValid() const;

    /**
     * @brief Get Property ID
     *
     * @return Property ID
     */
    quint8 getId() const;

    /**
     * @brief Set Property ID
     *
     * @param id    Property ID
     */
    void setId(const quint8 id);

    /**
     * @brief Get Property Data Type
     *
     * @return Data Type
     */
    DataType getDataType() const;

    /**
     * @brief Set Property Data Type
     *
     * @param dataType  Property Data Type
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setDataType(const DataType dataType);

    /**
     * @brief Get Property Access Permission
     *
     * @return Access Permission
     */
    AccessPermission getAccessPermission() const;

    /**
     * @brief Set Property Access Permission
     *
     * @param accessPermission  Property Access Permission
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setAccessPermission(const AccessPermission accessPermission);

    /**
     * @brief Get Property Name
     *
     * @return Property Name
     */
    QString getName() const;

    /**
     * @brief Set Property Name
     *
     * @param name  Property Name
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setName(const QString &name);

    /**
     * @brief Convert Property Info to binary (byte array)
     *
     * @return Byte array with binary representation of Property Info
     */
    QByteArray toBinary() const;

    /**
     * @brief Parse Property Info from binary (byte array)
     *
     * @param data              Binary data
     * @param startIndex        Start index of binary data
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool fromBinary(const QByteArray &data,
                    const int startIndex = 0);

private:
    /**
     * @brief Property ID
     */
    quint8 m_id;

    /**
     * @brief Property Data Type
     */
    DataType m_dataType;

    /**
     * @brief Property Access Permission
     */
    AccessPermission m_accessPermission;

    /**
     * @brief Property Name
     */
    QString m_name;
};
}

#endif // LIBDATABUS_COMMON_PROPERTYINFO_H
